package besta.moon.engine;

import java.sql.*;

import besta.moon.MoonException;
import besta.moon.MoonCode;
import besta.moon.sql.expression.Expressions;

public abstract class RowSource {

    public abstract boolean isScrollable();

    public abstract void beforeFirst() throws Exception;

    public boolean isBeforeFirst() throws SQLException {
        throw MoonException.create(MoonCode.RSET_FWDONLY);
    }

    public boolean isFirst() throws SQLException {
        throw MoonException.create(MoonCode.RSET_FWDONLY);
    }

    public abstract boolean first() throws Exception;

    public boolean previous() throws Exception {
        throw MoonException.create(MoonCode.RSET_FWDONLY);
    }

    public abstract boolean next() throws Exception;

    public boolean last() throws Exception {
        throw MoonException.create(MoonCode.RSET_FWDONLY);
    }

    public boolean isLast() throws Exception {
        throw MoonException.create(MoonCode.RSET_FWDONLY);
    }

    public boolean isAfterLast() throws SQLException, Exception {
        throw MoonException.create(MoonCode.RSET_FWDONLY);
    }

    public abstract void afterLast() throws Exception;

    public boolean absolute(int row) throws Exception {
        throw MoonException.create(MoonCode.RSET_FWDONLY);
    }

    public boolean relative(int rows) throws Exception {
        throw MoonException.create(MoonCode.RSET_FWDONLY);
    }

    public abstract int getRow() throws Exception;

    public abstract long getRowPosition();

    public abstract void setRowPosition(long rowPosition) throws Exception;

    public abstract void nullRow();

    public abstract void noRow();

    public abstract boolean rowInserted();

    public abstract boolean rowDeleted();

    public boolean hasAlias() {
        return true;
    }

    public void setAlias(String name) throws SQLException {
        throw MoonException.create(MoonCode.ALIAS_UNSUPPORTED);
    }

    public abstract void execute() throws Exception;

    public abstract boolean isExpressionsFromThisRowSource(Expressions columns);

}
